<?php


/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Cmspage
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
 
?>


<div class="headline">
  <h2>
    <?php echo $this->translate('Pages2');?>
  </h2>
  <div class="tabs">
    <?php
      // Render the menu
      echo $this->navigation()
        ->menu()
        ->setContainer($this->navigation)
        ->render();
    ?>
  </div>
</div>

<div class='layout_right cmspage_layout_right'>
  <div class="cmspages_gutter">
  <?php echo $this->form->render($this) ?>
    
  <?php if( $this->can_create): ?>
    <div class="quicklinks">
      <ul>
        <li>
          <a href='<?php echo $this->url(array(), 'cmspage_create', true) ?>' class='buttonlink icon_cmspage_new'><?php echo $this->translate('Post New Page');?></a>
        </li>
      </ul>
    </div>
  <?php endif; ?>
  
  </div>
</div>

<div class='layout_middle cmspage_layout_middle'>

  <?php if( $this->tag || ($this->user_id && $this->user($this->user_id)->getIdentity()) || $this->search):?>
    <div class='cmspages_result_filter_details'>
      <?php echo $this->translate('Showing pages posted'); ?>
      <?php if( $this->user_id && $this->user($this->user_id)->getIdentity()): ?>
        <?php echo $this->translate('by user %s', $this->htmlLink(
          $this->url(array('user'=>$this->user_id), 'cmspage_browse', true),
          $this->user($this->user_id)->getTitle()
        ));?>
      <?php endif; ?>
      <?php if ($this->tag): ?>
        <?php echo $this->translate('using tag #%s', $this->htmlLink(
	        $this->url(array('tag'=>$this->tag), 'cmspage_browse', true),
	        $this->tagObject ? $this->tagObject->text : $this->tag
        ));?>
      <?php endif; ?>
      <?php if ($this->search): ?>
        <?php echo $this->translate('with keyword %s', $this->htmlLink(
          $this->url(array('search'=>$this->search), 'cmspage_browse', true),
          $this->search
        ));?>
      <?php endif; ?>   
      <a href="<?php echo $this->url(array(), 'cmspage_browse', true) ?>">(x)</a>
    </div>
  <?php endif; ?>
  
  
  <?php if( $this->paginator->getTotalItemCount() > 0 ): ?>

    <div class="cmspages_results">
      <h3 class="sep">
        <span>
          <?php if ($this->categoryObject): ?>
            <?php echo $this->translate($this->categoryObject->category_name); ?>
          <?php else: ?>  
            <?php echo $this->translate('All Categories'); ?>
          <?php endif; ?>
        </span>
      </h3>    
        <?php // echo $this->translate(array('%s location found','%s locations found', $this->paginator->getTotalItemCount()), $this->paginator->getTotalItemCount()); ?></span></h3>
        
      <ul class="cmspages_browse">
        <?php foreach( $this->paginator as $item ): ?>
          <li>
            <div class="cmspage_title">
              <?php echo $this->htmlLink($item->getHref(), $item->getTitle()) ?>
                <?php if( $item->featured ): ?>
                  <img src='application/modules/Cmspage/externals/images/featured.png' class='cmspage_title_icon_featured' />
                <?php endif;?>
                <?php if( $item->sticky ): ?>
                  <img src='application/modules/Cmspage/externals/images/sticky.png' class='cmspage_title_icon_sticky' />
                <?php endif;?>
            </div>
            <?php if ($this->show_page_details): ?>
              <div class="cmspage_details">
                <?php echo $this->translate('Posted by %s', $this->htmlLink($item->getOwner()->getHref(), $item->getOwner()->getTitle()));?>
                -
                <?php echo $this->timestamp(strtotime($item->creation_date)) ?>
              </div>
            <?php endif; ?>
          </li>
        <?php endforeach; ?>
      </ul>  
  
    </div>
    <!-- /cmspages_results -->
    
    <?php echo $this->paginationControl($this->paginator, null, null, array(
      'query' => $this->formValues
    )); ?>  
    
  <?php elseif( $this->category || $this->show == 1 || $this->search || $this->user_id || $this->tag):?>
    <div class="tip">
      <span>
        <?php echo $this->translate('Nobody has posted a page with that criteria.');?>
        <?php if ($this->can_create): ?>
          <?php echo $this->translate('Be the first to <a href=\'%s\'>post</a> one!', $this->url(array(), 'cmspage_create')); ?>
        <?php endif; ?>
      </span>
    </div>
  <?php else:?>
    <div class="tip">
      <span>
        <?php echo $this->translate('Nobody has posted a page yet.');?>
        <?php if ($this->can_create): ?>
          <?php echo $this->translate('Be the first to <a href=\'%s\'>post</a> one!', $this->url(array(), 'cmspage_create')); ?>
        <?php endif; ?>
      </span>
    </div>
  <?php endif; ?>
  
</div>

